//
//  DemoHelp.m
//  Demo
//
//  Created by colawh on 2019/3/13.
//  Copyright © 2019年 colawhdfws. All rights reserved.
//

#import "DemoHelp.h"

@implementation DemoHelp

+ (UILabel *)getLbByFont:(CGFloat)fontx{
    UILabel *lb = [[UILabel alloc]init];
    lb.textColor = [UIColor blackColor];
    lb.font = [UIFont systemFontOfSize:fontx];
    return lb;
}

+ (void)setLbHuggingAndCompress:(UILabel *)lb{
    [lb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
    [lb setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
}

+ (CGFloat)getViewHeight:(UIView *)view{
    [view.superview layoutIfNeeded];
    [view updateConstraintsIfNeeded];
    CGFloat height = [view.superview systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
    return height;
}
+ (CGFloat)getLB:(UILabel *)lb HeightByWidth:(CGFloat)width{
    CGSize size = [lb.text boundingRectWithSize:CGSizeMake(width, MAXFLOAT)
                                          options:NSStringDrawingUsesLineFragmentOrigin
                                       attributes:@{NSFontAttributeName:lb.font}
                                        context:nil].size;
    return size.height;
}
+ (BOOL)judgeIsEmptyWithString:(NSString *)string {
    if ( [string isEqual:[NSNull null]]||string.length == 0 || [string isEqualToString:@""] || string == nil || string == NULL )
    {
        return YES;
        
    }
    return NO;
    
}

@end
